class ContextManager:
    def __enter__(self):
        print('Entering context manager')

    def __exit__(self, exc_type, exc_val, exc_tb):
        print('Exiting context manager')
        if exc_type is not None:
            print('Caught exception: ({}, {})'.format(exc_type, exc_val))
            # print(exc_type, exc_val, exc_tb)
        else:
            print('Exiting context manager with no exception')


def normal_run():
    with ContextManager():
        print('>> inside context manager')


def run_with_exception():
    try:
        with ContextManager():
            print('>> inside context')
            raise RuntimeError('Something went wrong')
    except RuntimeError as e:
        pass


if __name__ == '__main__':
    # normal_run()
    run_with_exception()
